package com.shuyuansystem.controller;

import com.shuyuansystem.pojo.Product;
import com.shuyuansystem.service.ProductService;
import com.shuyuansystem.utils.PageResult;
import com.shuyuansystem.utils.QueryPageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/Main")
public class ProductController {
    @Autowired
    private ProductService productService;
    @RequestMapping("/findAllproducts")
    public List<Product> findAllproducts(){
        List<Product> products = productService.getAllProduct();
        for (Product product : products) {
            System.out.println("Before serialization: " + product);
        }

        return productService.getAllProduct();
    }
    //分页查询
    @RequestMapping("/findPage.do")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean){
        return productService.findPage(queryPageBean);
    }

}
